using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Sec_scan漏洞扫描系统
{
    public partial class Sec_Scan_PassWord : Form
    {
        public Sec_Scan_PassWord()
        {
            InitializeComponent();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //更新系统密码
            if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("密码不能为空！");
                return;
            }
            else
            {
                if(textBox1.Text == textBox2.Text)
                {
                    //密码一致的情况下 先传出密码
                    Sec_Api.Sec_SystemConfigAllAPI.PassWords = textBox2.Text;
                    //执行密码更新
                    Sec_System.Sec_SystemConfigAll.PassWordConfig(Sec_Api.Sec_SystemConfigAllAPI.P1);
                    if(Sec_Api.Sec_SystemConfigAllAPI.ExpOk.ToString().Length > 1)
                    {
                        MessageBox.Show(Sec_Api.Sec_SystemConfigAllAPI.ExpOk.ToString());
                    }
                    else
                    {
                        MessageBox.Show(Sec_Api.Sec_SystemConfigAllAPI.ExpOptions.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("两次密码输入不一致，请进行确认！");
                    return;
                }
            }
        }

        private void PassWord_Load(object sender, EventArgs e)
        {
            //加载系统账号
            Sec_System.Sec_SystemConfigAll.UserWordRefer(Sec_Api.Sec_SystemConfigAllAPI.P1);
            try
            {
                if (Sec_Api.Sec_SystemConfigAllAPI.User.ToString().Length > 1)
                {
                    textBox3.Text = Sec_Api.Sec_SystemConfigAllAPI.User.ToString();
                }
                else
                {
                    MessageBox.Show(Sec_Api.Sec_SystemConfigAllAPI.ExpOptions.ToString());
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
